package com.example.demo.redis.service.impl;

import com.example.demo.model.Material;
import com.example.demo.redis.mapper.RedisMapper;
import com.example.demo.redis.service.RedisService;
import com.example.demo.util.Result;
import com.example.demo.util.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.cache.annotation.Cacheable;
import java.util.List;

/**
 * Created by 86151 on 2018/12/26.
 */
@Service
public class RedisServiceImpl implements RedisService{
    @Autowired
    private RedisMapper redisMapper;

    @Override
    @Cacheable(value = "testRedis",key = "'test'")
    public Result<List<Material>> testRedis() {
        System.out.println("我操作数据库获取到的数据！");
        List<Material> all = redisMapper.findAll();
        return ResultVo.success(all);
    }
}
